<!--页面标题-->
<template>
  <div class="pageTitle" :class="['level' + level, border ? 'isBorder' : '', padding ? 'isPadding' : '']">
    <div v-if="goBack" class="back-item" @click="toBackPage">
      <img class="back-img" src="../../../src/assets/images/goBack.png" alt="" />
      <label class="goBack">返回</label>
    </div>
    <div class="title-tag"></div>
    <div class="title">{{ title }}</div>
  </div>
</template>
<script lang="ts" setup>
  import { useRouter } from 'vue-router';
  const props = defineProps({
    title: {
      type: String,
      // default: '默认标题',
    },
    goBack: {
      type: Boolean,
      default: false,
    },
    level: {
      type: Number,
      default: 1,
    },
    border: {
      type: Boolean,
      default: true,
    },
    padding: {
      type: Boolean,
      default: true,
    },
    backType: {
      type: Boolean,
      default: true
    }
  });
  const emit = defineEmits(['goBack']);
  const Router = useRouter();
  function toBackPage() {
    emit('goBack', '');
  }
</script>
<style lang="less" scoped>
  .pageTitle {
    width: 100%;
    height: 48px;
    display: flex;
    background: #ffffff;
    user-select: none;
    .back-item {
      margin-right: 16px;
      cursor: pointer;
      .back-img {
        margin-right: 10px;
        display: inline;
        line-height: 48px;
      }
      .goBack {
        font-size: 14px;
        color: #303133;
        line-height: 48px;
      }
    }
    .title-tag {
      width: 2px;
      height: 14px;
      background: #c11a20;
      margin-right: 8px;
      display: inline;
      margin-top: 18px;
    }
    .title {
      font-weight: bold;
      line-height: 48px;
      color: #303133;
    }
  }
  .isBorder {
    border-bottom: 1px solid #dcdfe6;
  }
  .isPadding {
    padding: 0 16px;
  }
  .level1 {
    font-size: 16px;
  }
  .level2 {
    font-size: 14px;
  }
</style>
